package tlias.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import tlias.pojo.Result;
import tlias.utils.AliyunUtils;


@RestController
@Slf4j
public class UploadController {
    private final AliyunUtils a;

    public UploadController(AliyunUtils a) {
        this.a = a;
    }


    @PostMapping("/upload")
    public Result submit(MultipartFile file) throws Exception {
        String url = "无法返回地址";
        if(file.getOriginalFilename()!=null){
            url = a.upload(file.getBytes(), file.getOriginalFilename());
        }
        return Result.success(url);
    }
}
